import * as price from './action-type'
import API from '@/api/api'
/*
  actions 只是描述了有事情发生了这一事实
*/
// 保存币种换算信息
export const saveUsdt = () => {
  return (dispatch) => {
    API.getUSDT().then(res => {
      if (res.code == '100200') {
        let regEx = /[^\d|^\.|^\-]/g;
        for (let i in res.data) {
          res.data[i] = res.data[i].replace(regEx, '') * 1;
        }
        let usdtInfo = res.data;
        dispatch({
          type: price.SAVE_USDT,
          usdtInfo
        })
      }
    });
  }
}
